<?php
	require(DIR_TEMPLATE . C('config_template')."/setting/setting.php" );
	$config_template = C('config_template');
	$config_theme = C('config_theme');
	$product_product_row = isset($config_theme['product_product_row']) ?  $config_theme['product_product_row'] : 3;
	$span = floor(12 / $product_product_row);
?>
<?php echo $header; ?>
<div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
    	<?php echo $breadcrumb['separator']; ?>
    	<a itemprop="url" href="<?php echo $breadcrumb['href']; ?>">
    		<span itemprop="title"><?php echo $breadcrumb['text']; ?></span>
    	</a>
    </span>
    <?php } ?>
</div>

<div>
<?php if ($SPAN[0]) { ?>
  <div class="span<?php echo $SPAN[0]; ?>">
    <?php echo $column_left; ?>
  </div>
<?php } ?>

<div class="span<?php echo $SPAN[1];?>">
<div id="content"><?php echo $content_top; ?>
  <div itemscope itemtype="http://data-vocabulary.org/Product" class="product-info">
	<div class="row-fluid">
    <?php if ($thumb || $images) { ?>
    <div class="span6 image-container">
	  <?php if($special || $discounts || $text_promotion) { ?>
		<div class="product-label-special label"><?php echo $_['text_sale']; ?></div>
	  <?php } ?>
      <?php if ($thumb) { ?>
      <div class="image"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="colorbox">
      <img itemprop="image" src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" data-zoom-image="<?php echo $popup; ?>" class="product-image-zoom" />
      </a>
      </div>
      <?php } ?>
      <?php if (count($images) > 1) { ?>
       <div class="image-additional slide carousel" id="image-additional"><div class="carousel-inner">
	   <div class="item">
        <?php foreach ($images as $i => $image) { ?>
		<?php if ($i > 0 && $i % 3 == 0) { ?>
		</div><div class="item">
		<?php } ?>
        <a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="colorbox" data-zoom-image="<?php echo $image['popup']; ?>" data-image="<?php echo $image['thumb']; ?>"><img src="<?php echo $image['small']; ?>" alt="<?php echo $heading_title; ?>" class="product-image-zoom" /></a>
        <?php } ?>
	   </div>
      </div>
      <div class="carousel-control left" href="#image-additional" data-slide="prev">&lsaquo;</div>
      <div class="carousel-control right" href="#image-additional" data-slide="next">&rsaquo;</div>
      </div>
	  <script type="text/javascript">
		$('#image-additional .item:first').addClass('active');
		$('#image-additional').carousel({interval:false})
	  </script>
      <?php } ?>
      <div class="share clearfix">
          <div class="addthis_default_style"><a class="addthis_button_compact"><?php echo $_['text_share']; ?></a> <a class="addthis_button_email"></a><a class="addthis_button_print"></a> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a></div>
          <script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js"></script>
      </div>
    </div>
    <?php } ?>
    <div class="span6">
	  <h2 itemprop="name"><?php echo $heading_title; ?></h2>
	  <?php if (C('config_review_status')) { ?>
      <div class="review">
        <div itemprop="review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">
        	<meta itemprop="rating" content="<?php echo $rating;?>" />
        	<meta itemprop="count" content="<?php echo $reviews;?>" />
        	<img src="themes/<?php echo $config_template;?>/image/stars-<?php echo $rating; ?>.png" alt="<?php echo $text_reviews; ?>" />&nbsp;&nbsp;
        	<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $text_reviews; ?></a>&nbsp;&nbsp;
        	|&nbsp;&nbsp;<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $_['text_write']; ?></a></div>   
      </div>
      <?php } ?>
      <div class="description">
        <?php if ($manufacturer) { ?>
        <span><?php echo $_['text_manufacturer']; ?></span> <a href="<?php echo $manufacturers; ?>"><span itemprop="brand"><?php echo $manufacturer; ?></span></a><br />
        <?php } ?>
        <span><?php echo $_['text_model']; ?></span> <?php echo $model; ?><br />
        <?php if ($reward) { ?>
        <span><?php echo $_['text_reward']; ?></span> <?php echo $reward; ?><br />
        <?php } ?>
        <span><?php echo $_['text_stock']; ?></span> <?php echo $stock; ?>
        <?php if ($gifts) { ?><br />        
        <?php foreach($gifts as $gift) { ?>
        <a href="<?php echo $gift['href']?>" target="_blank"><img class="mg5" src="<?php echo $gift['thumb']?>" alt="<?php echo $gift['name']?>" title="<?php echo $_['text_gift']; ?>"> x <?php echo $gift['qty']?></a>
        <?php } ?>
        <?php } ?>
      </div>
	   
	  <div class="price-cart">
      <?php if ($price) { ?>
      <div class="price" itemprop="offerDetails" itemscope itemtype="http://data-vocabulary.org/Offer">
        <meta itemprop="currency" content="<?php echo $currency_code;?>" />
        <?php if (!$special) { ?>
       <span itemprop="price"><?php echo $price; ?></span>
        <?php } else { ?>
        <span class="price-old"><?php echo $price; ?></span>
        <span class="price-new" itemprop="price"><?php echo $special; ?></span>
        <?php if ($text_promotion) { ?>
        <span class="label label-important"><?php echo $text_promotion;?></span>
        <?php } ?>
        <?php } ?>
        </div>
        <?php if ($special && $text_promotion) { ?>
        <div class="clearfix"></div>
        <?php } ?>
	  <?php } ?>
	  <div class="product-extra">
          <div class="quantity-adder pull-left">
          <?php echo $_['text_qty']; ?>
          <input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
            <span class="add-up add-action"><span class="icon-caret-up"></span></span> <span class="add-down add-action"><span class="icon-caret-down"></span></span>
          </div>
          <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
          &nbsp;
          <input type="button" value="<?php echo $_['button_cart']; ?>" id="button-cart" class="button" />
         
      </div>
	  <?php if ($minimum > 1) { ?>
        <div class="minimum"><?php echo $text_minimum; ?></div>
        <?php } ?>
	  </div>
	  
	  <div class="compare-wish"><span class="links"><a class="wishlist" onclick="addToWishList('<?php echo $product_id; ?>');"><?php echo $_['button_wishlist']; ?></a>
            <a class="compare" onclick="addToCompare('<?php echo $product_id; ?>');"><?php echo $_['button_compare']; ?></a></span>
	  </div>
		
       <?php if ($price) { ?>
      <div class="price-other">
        <?php if ($tax) { ?>
        <span class="price-tax"><?php echo $_['text_tax']; ?> <?php echo $tax; ?></span><br />
        <?php } ?>
        <?php if ($points) { ?>
        <span class="reward"><small><?php echo $_['text_points']; ?> <?php echo $points; ?></small></span><br />
        <?php } ?>
        <?php if ($discounts) { ?>
        <br />
        <div class="discount">
          <table class="table table-bordered">
          <tr><th colspan="2"><?php echo $_['text_discount'];?></th></tr>
          <tr>
          	<td><?php echo $_['text_quantity'];?></td>
          	<?php foreach ($discounts as $discount) { ?>
	        <td><?php echo sprintf($_['text_discount_qty'], $discount['quantity']); ?></td>
	         <?php } ?>
          </tr>
          <tr>
          	<td><?php echo $_['text_price_unit']?></td>
          	<?php foreach ($discounts as $discount) { ?>
	        <td><?php echo $discount['price']; ?></td>
	        <?php } ?>
          </tr>
          </table>          
        </div>
        <?php } ?>
      </div>
      <?php } ?>
	  
      <?php if ($options) { ?>
      <div class="options">
        <h2><?php echo $_['text_option']; ?></h2>
        <?php foreach ($options as $option) { ?>
        <?php if ($option['type'] == 'select') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <select name="option[<?php echo $option['product_option_id']; ?>]">
            <option value=""><?php echo $_['text_select']; ?></option>
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
            </option>
            <?php } ?>
          </select>
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'radio') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <?php foreach ($option['option_value'] as $option_value) { ?>
          <input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" />
          <label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
          </label>
          <br />
          <?php } ?>
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'checkbox') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <?php foreach ($option['option_value'] as $option_value) { ?>
          <input type="checkbox" name="option[<?php echo $option['product_option_id']; ?>][]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" />
          <label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
          </label>
          <br />
          <?php } ?>
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'image') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <table class="option-image">
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <tr>
              <td style="width: 1px;"><input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" /></td>
              <td><label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" /></label></td>
              <td><label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
                  <?php if ($option_value['price']) { ?>
                  (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
                  <?php } ?>
                </label></td>
            </tr>
            <?php } ?>
          </table>
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'text') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['option_value']; ?>" />
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'textarea') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <textarea name="option[<?php echo $option['product_option_id']; ?>]" cols="40" rows="5"><?php echo $option['option_value']; ?></textarea>
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'file') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <input type="button" value="<?php echo $_['button_upload']; ?>" id="button-option-<?php echo $option['product_option_id']; ?>" class="button">
          <input type="hidden" name="option[<?php echo $option['product_option_id']; ?>]" value="" />
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'date') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['option_value']; ?>" class="date" />
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'datetime') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['option_value']; ?>" class="datetime" />
        </div>
        <br />
        <?php } ?>
        <?php if ($option['type'] == 'time') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['option_value']; ?>" class="time" />
        </div>
        <br />
        <?php } ?>
        <?php } ?>
      </div>
      <?php } ?>
    </div>
  </div>
  </div>

   <?php if ($packages) { ?>
  <div class="product-related" id="product-packages">
   <div class="box-heading"><h3> <span><?php echo $_['text_package']; ?></span></h3></div>
    <div class="box-product">
  <div class="row-fluid">
    <?php foreach ($packages as $i => $product) { ?>
    <?php if($i > 0 && $i % 3 == 0) { ?>
      </div><div class="row-fluid">
    <?php } ?>
    <div class="span<?php echo $span;?> product-block">
    <?php if ($product['thumb']) { ?>
      <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
      <?php } ?>
     <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
   <div class="group-item">
    <div class="price-cart">
      <?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
      </div>
      <?php } ?>
 
      <div class="checkbox">
        <input type="checkbox" name="promotion[<?php echo $product['product_package_id'];?>]" value="<?php echo $product['product_id'];?>" />
      </div>
    </div>
    </div>
  </div>
  <?php } ?>
  </div>
  </div>
  </div>
  <?php } ?>

  <div class="tabs-group">
  <div class="row-fluid">
  <div id="tabs" class="span12 htabs"><a href="#tab-description"><?php echo $_['tab_description']; ?></a>
    <?php if ($attribute_groups) { ?>
    <a href="#tab-attribute"><?php echo $_['tab_attribute']; ?></a>
    <?php } ?>
    <?php if (C('config_review_status')) { ?>
    <a href="#tab-review"><?php echo sprintf($_['tab_review'], $reviews); ?></a>
    <?php } ?>
    <?php if (C('config_faq_status')) { ?>
    <a href="#tab-faq"><?php echo $_['tab_faq']; ?></a>
    <?php } ?>
  </div>
  </div>
  <div id="tab-description" class="tab-content">
    <?php echo $description; ?>
    <?php if ($tags) { ?>
    <div class="tags"><b><?php echo $_['text_tags']; ?></b>
    <?php for ($i = 0; $i < count($tags); $i++) { ?>
    <?php if ($i < (count($tags) - 1)) { ?>
    <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a>,
    <?php } else { ?>
    <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a>
    <?php } ?>
    <?php } ?>
    </div>
    <?php } ?>
  </div>
  <?php if ($attribute_groups) { ?>
  <div id="tab-attribute" class="tab-content">
    <table class="attribute">
      <?php foreach ($attribute_groups as $attribute_group) { ?>
      <thead>
        <tr>
          <td colspan="2"><?php echo $attribute_group['name']; ?></td>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
        <tr>
          <td><?php echo $attribute['name']; ?></td>
          <td><?php echo $attribute['text']; ?></td>
        </tr>
        <?php } ?>
      </tbody>
      <?php } ?>
    </table>
  </div>
  <?php } ?>
  <?php if (C('config_review_status')) { ?>
  <div id="tab-review" class="tab-content">
    <div id="review"></div>
    <h2 id="review-title"><?php echo $_['text_write']; ?></h2>
    <b><?php echo $_['entry_name']; ?></b><br />
    <input type="text" name="name" value="" />
    <br />
	<b><?php echo $_['entry_email']; ?></b><br />
    <input type="text" name="email" value="" />
    <br />
    <b><?php echo $_['entry_review']; ?></b>
    <textarea name="text" cols="40" rows="8" style="width: 98%;"></textarea>
    <span style="font-size: 11px;"><?php echo $_['text_note']; ?></span><br />
    <br />
    <b><?php echo $_['entry_rating']; ?></b> <span><?php echo $_['entry_bad']; ?></span>&nbsp;
    <input type="radio" name="rating" value="1" />
    &nbsp;
    <input type="radio" name="rating" value="2" />
    &nbsp;
    <input type="radio" name="rating" value="3" />
    &nbsp;
    <input type="radio" name="rating" value="4" />
    &nbsp;
    <input type="radio" name="rating" value="5" />
    &nbsp;<span><?php echo $_['entry_good']; ?></span><br />
    <br />
    <b><?php echo $_['entry_captcha']; ?></b><br />
    <input type="text" name="captcha" value="" />
    <br />
    <img src="<?php echo U('product/product/captcha');?>" alt="" id="captcha" /><br />
    <br />
    <div class="buttons">
      <div class="right"><a id="button-review" class="button"><?php echo $_['button_continue']; ?></a></div>
    </div>
  </div>
  <?php } ?>
  <?php if (C('config_faq_status')) { ?>
  <div id="tab-faq" class="tab-content">
    <div id="faq"></div>
    <h2 id="faq-title"><?php echo $_['text_faq_write']; ?></h2>
    <b><?php echo $_['entry_name']; ?></b><br />
    <input type="text" name="faq_name" value="" />
    <br />
	<b><?php echo $_['entry_email']; ?></b><br />
    <input type="text" name="faq_email" value="" />
    <br />
    <b><?php echo $_['entry_question']; ?></b>
    <textarea name="question" cols="40" rows="8" style="width: 98%;"></textarea>
    <span style="font-size: 11px;"><?php echo $_['text_note']; ?></span><br />    
    <b><?php echo $_['entry_captcha']; ?></b><br />
    <input type="text" name="faq_captcha" value="" />
    <br />
    <img src="<?php echo U('product/product/captcha');?>" alt="" id="faq_captcha" /><br />
    <br />
    <div class="buttons">
      <div class="right"><a id="button-faq" class="button"><?php echo $_['button_continue']; ?></a></div>
    </div>
  </div>
  <?php } ?>  
  </div>
  <?php if ($products) { ?>
	<div class="product-related">
	 <div class="box-heading"><h3> <span><?php echo $_['tab_related']; ?> (<?php echo count($products); ?>)</span></h3></div>
    <div class="box-product">
	<div class="row-fluid">
	  <?php foreach ($products as $i => $product) { ?>
		<?php if($i > 0 && $i % 3 == 0) { ?>
		  </div><div class="row-fluid">
		<?php } ?>
	  <div class="span<?php echo $span;?> product-block">
	  <?php if ($product['thumb']) { ?>
      <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
      <?php } ?>
     <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
	 <div class="group-item"> 
	  <?php if ($product['rating']) { ?>
      <div class="rating"><img src="catalog/view/theme/<?php echo $config_template;?>/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
      <?php } ?>
	  <div class="price-cart">
      <?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
      </div>
      <?php } ?>
 
      <div class="cart">
        <input type="button" value="<?php echo $_['button_cart']; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
      </div>
	  </div>
	  </div>
	</div>
	<?php } ?>
  </div>
  </div>
  </div>
  <?php } ?>
  
  <?php echo $content_bottom; ?></div>
<script type="text/javascript" src="themes/<?php echo $config_template; ?>/javascript/elevatezoom/elevatezoom-min.js"></script>
<script type="text/javascript">
    $("#image").elevateZoom({gallery:'image-additional', cursor: 'pointer', galleryActiveClass: 'active'});
</script>
<script type="text/javascript"><!--
$('.colorbox').colorbox({
	overlayClose: true,
	opacity: 0.5,
	rel: "colorbox"
});
//--></script> 
<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, #product-packages input[\'checkbox\']:checked'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			
			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
					}
				}
			} 
			
			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="themes/default/image/close.png" alt="" class="close" /></div>');
					
				$('.success').fadeIn('slow');
					
				$('#cart-total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
});
//--></script>
<?php if ($options) { ?>
<script type="text/javascript" src="static/javascript/jquery/ajaxupload.js"></script>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'file') { ?>
<script type="text/javascript"><!--
new AjaxUpload('#button-option-<?php echo $option['product_option_id']; ?>', {
	action: 'index.php?route=product/product/upload',
	name: 'file',
	autoSubmit: true,
	responseType: 'json',
	onSubmit: function(file, extension) {
		$('#button-option-<?php echo $option['product_option_id']; ?>').after('<img src="themes/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
		$('#button-option-<?php echo $option['product_option_id']; ?>').attr('disabled', true);
	},
	onComplete: function(file, json) {
		$('#button-option-<?php echo $option['product_option_id']; ?>').attr('disabled', false);
		
		$('.error').remove();
		
		if (json['success']) {
			alert(json['success']);
			
			$('input[name=\'option[<?php echo $option['product_option_id']; ?>]\']').attr('value', json['file']);
		}
		
		if (json['error']) {
			$('#option-<?php echo $option['product_option_id']; ?>').after('<span class="error">' + json['error'] + '</span>');
		}
		
		$('.loading').remove();	
	}
});
//--></script>
<?php } ?>
<?php } ?>
<?php } ?>
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
	$('#review').fadeOut('slow');
		
	$('#review').load(this.href);
	
	$('#review').fadeIn('slow');
	
	return false;
});			

$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');

$('#button-review').bind('click', function() {
	$.ajax({
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		type: 'post',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&email=' + encodeURIComponent($('input[name=\'email\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-review').attr('disabled', true);
			$('#review-title').after('<div class="attention"><img src="themes/default/image/loading.gif" alt="" /> <?php echo $_['text_wait']; ?></div>');
		},
		complete: function() {
			$('#button-review').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(data) {
			if (data['error']) {
				$('#review-title').after('<div class="warning">' + data['error'] + '</div>');
			}
			
			if (data['success']) {
				$('#review-title').after('<div class="success">' + data['success'] + '</div>');
								
				$('input[name=\'name\']').val('');
				$('input[name=\'email\']').val('');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
});
//--></script> 
<script type="text/javascript"><!--
$('#faq .pagination a').live('click', function() {
	$('#faq').fadeOut('slow');
	$('#faq').load(this.href);
	$('#faq').fadeIn('slow');
	
	return false;
});			

$('#faq').load('index.php?route=product/product/faq&product_id=<?php echo $product_id; ?>');

$('#button-faq').bind('click', function() {
	$.ajax({
		url: 'index.php?route=product/product/writefaq&product_id=<?php echo $product_id; ?>',
		type: 'post',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'faq_name\']').val()) + '&email=' + encodeURIComponent($('input[name=\'faq_email\']').val()) + '&question=' + encodeURIComponent($('textarea[name=\'question\']').val()) + '&captcha=' + encodeURIComponent($('input[name=\'faq_captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-faq').attr('disabled', true);
			$('#faq-title').after('<div class="attention"><img src="themes/default/image/loading.gif" alt="" /> <?php echo $_['text_wait']; ?></div>');
		},
		complete: function() {
			$('#button-faq').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(data) {
			if (data['error']) {
				$('#faq-title').after('<div class="warning">' + data['error'] + '</div>');
			}
			
			if (data['success']) {
				$('#faq-title').after('<div class="success">' + data['success'] + '</div>');
								
				$('input[name=\'faq_name\']').val('');
				$('input[name=\'faq_email\']').val('');
				$('textarea[name=\'question\']').val('');
				$('input[name=\'faq_captcha\']').val('');
			}
		}
	});
});
//--></script> 
<script type="text/javascript"><!--
$('#tabs a').tabs();
//--></script> 
<script type="text/javascript" src="static/javascript/jquery/ui/jquery-ui-timepicker-addon.js"></script> 
<script type="text/javascript"><!--
$(document).ready(function() {
	if ($.browser.msie && $.browser.version == 6) {
		$('.date, .datetime, .time').bgIframe();
	}

	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	$('.datetime').datetimepicker({
		dateFormat: 'yy-mm-dd',
		timeFormat: 'h:m'
	});
	$('.time').timepicker({timeFormat: 'h:m'});
});
//--></script> 
</div>

<?php if ($SPAN[2]) { ?>
  <div class="span<?php echo $SPAN[2]; ?>">
    <?php echo $column_right; ?>
  </div>
<?php } ?>
</div>
<?php echo $footer; ?>